<html>
<head><meta charset="utf-8"><title>Allow skipping fields with built-in derives · t-lang · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/index.html">t-lang</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Allow.20skipping.20fields.20with.20built-in.20derives.html">Allow skipping fields with built-in derives</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="210699504"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Allow%20skipping%20fields%20with%20built-in%20derives/near/210699504" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Aaron Hill <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Allow.20skipping.20fields.20with.20built-in.20derives.html#210699504">(Sep 21 2020 at 03:55)</a>:</h4>
<p>I'm thinking of writing up an RFC to allow skipping fields for built-in derives (where it makes sense) - e.g. <code>PartialEq</code>, <code>PartialOrd</code>, <code>Hash</code>,  and <code>Debug</code>.</p>
<p>The idea is to add helper attributes for each of those derive macros (<code>#[partialeq]</code>, <code>#[partialord]</code>, etc.). The only supported form would be <code>#[partialeq(ignore)]</code> on a field, which would skip generating code for that field.</p>
<p>Derive helper attributes effectively have a single global namespace - all proc-macros can see all helper attributes, and multi derive macros can register a helper attr with the same name. To avoid conflicts, the builtin derive macros would ignore these attributes if there are any other applied derive macros which also register them (and emit a warning). Hopefully, no one is using helper attributes with any of those names - but if they are, we won't start changing the behavior of their derived traits. Any such proc macros could then provide alternative names to allow better interoperability with the builtin derive macros.</p>
<p>I considered more complicated workarounds, like making helper attributes full-fledged importable things (like attribute macros are). However, this seems like it would result in at least one of the following:</p>
<ol>
<li>Make writing proc-macros an enormous pain (you would essentially have to re-implement path resolution yourself to support all possible invocations)</li>
<li>Be weirdly inconsistent compared to other imports (e.g. no re-exporting), which would be bad for facade crates like <code>serde</code> and <code>pin-project</code></li>
<li>Require re-writing/normalizing helper attribute paths before invoking macros, which seems against the spirit of proc-macros.</li>
</ol>
<p>I haven't been able to find any recent work done in this area. Are there any issues I should know about before I start writing up a pre-rfc?</p>



<a name="210699576"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Allow%20skipping%20fields%20with%20built-in%20derives/near/210699576" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Aaron Hill <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Allow.20skipping.20fields.20with.20built-in.20derives.html#210699576">(Sep 21 2020 at 03:57)</a>:</h4>
<p>I know crates like <code>derivative</code> exist, but many library crates aren't going to pull in a proc-macro dependency just to make writing some impls more convenient. So, not having this in libcore effectively means that many crates will be permanently stuck writing manual impls (which are also crates that might benefit from it the most)</p>



<a name="210699693"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Allow%20skipping%20fields%20with%20built-in%20derives/near/210699693" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Allow.20skipping.20fields.20with.20built-in.20derives.html#210699693">(Sep 21 2020 at 04:00)</a>:</h4>
<p><span class="user-mention" data-user-id="125294">@Aaron Hill</span> The biggest issue I'd be concerned about is whether any other crate in the ecosystem currently uses helper attributes with those names.</p>



<a name="210699706"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Allow%20skipping%20fields%20with%20built-in%20derives/near/210699706" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Allow.20skipping.20fields.20with.20built-in.20derives.html#210699706">(Sep 21 2020 at 04:01)</a>:</h4>
<p>Could you search for <code>#[partialeq</code>, <code>#[partialord</code>, and similar via some code search sites and get an idea of whether they appear anywhere?</p>



<a name="210699751"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Allow%20skipping%20fields%20with%20built-in%20derives/near/210699751" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Allow.20skipping.20fields.20with.20built-in.20derives.html#210699751">(Sep 21 2020 at 04:02)</a>:</h4>
<p>Also, I think it'd be reasonable to capitalize them just like the trait: <code>#[PartialEq(ignore)]</code> for instance.</p>



<a name="210699753"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Allow%20skipping%20fields%20with%20built-in%20derives/near/210699753" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Allow.20skipping.20fields.20with.20built-in.20derives.html#210699753">(Sep 21 2020 at 04:02)</a>:</h4>
<p>(which might have the advantage of further avoiding conflicts; you should check)</p>



<a name="210699766"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Allow%20skipping%20fields%20with%20built-in%20derives/near/210699766" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Allow.20skipping.20fields.20with.20built-in.20derives.html#210699766">(Sep 21 2020 at 04:03)</a>:</h4>
<p>This concept seems reasonable to me.</p>



<a name="210699773"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Allow%20skipping%20fields%20with%20built-in%20derives/near/210699773" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jane Lusby <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Allow.20skipping.20fields.20with.20built-in.20derives.html#210699773">(Sep 21 2020 at 04:03)</a>:</h4>
<p>could these attributes be reserved at an edition boundary?</p>



<a name="210699775"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Allow%20skipping%20fields%20with%20built-in%20derives/near/210699775" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Allow.20skipping.20fields.20with.20built-in.20derives.html#210699775">(Sep 21 2020 at 04:03)</a>:</h4>
<p>You will need to define what precisely those attributes mean for various types of types. For instance, what if someone puts <code>#[PartialEq(ignore)]</code> on an enum variant?</p>



<a name="210699789"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Allow%20skipping%20fields%20with%20built-in%20derives/near/210699789" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Allow.20skipping.20fields.20with.20built-in.20derives.html#210699789">(Sep 21 2020 at 04:03)</a>:</h4>
<p>And you'll want to specify that <code>#[PartialEq(ignore)]</code> works syntactically inside a tuple struct, or an enum struct variant, or all the places it could reasonably appear in a <code>derive(PartialEq)</code>.</p>



<a name="210699844"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Allow%20skipping%20fields%20with%20built-in%20derives/near/210699844" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Allow.20skipping.20fields.20with.20built-in.20derives.html#210699844">(Sep 21 2020 at 04:04)</a>:</h4>
<p><span class="user-mention silent" data-user-id="220273">Jane Lusby</span> <a href="#narrow/stream/213817-t-lang/topic/Allow.20skipping.20fields.20with.20built-in.20derives/near/210699773">said</a>:</p>
<blockquote>
<p>could these attributes be reserved at an edition boundary?</p>
</blockquote>
<p>I think it'd be possible to do that, if needed. They could also go by longer names (e.g. <code>core::something::attrs::PartialEq(ignore)</code>) before that edition boundary.</p>



<a name="210699854"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Allow%20skipping%20fields%20with%20built-in%20derives/near/210699854" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Allow.20skipping.20fields.20with.20built-in.20derives.html#210699854">(Sep 21 2020 at 04:05)</a>:</h4>
<p>(Also, I hope this sets a precedent that'll apply just as well for things like <code>derive(Display)</code>.)</p>



<a name="210699857"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Allow%20skipping%20fields%20with%20built-in%20derives/near/210699857" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Allow.20skipping.20fields.20with.20built-in.20derives.html#210699857">(Sep 21 2020 at 04:05)</a>:</h4>
<p>(Or <code>#[Debug(ignore)]</code>.)</p>



<a name="210699913"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Allow%20skipping%20fields%20with%20built-in%20derives/near/210699913" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jane Lusby <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Allow.20skipping.20fields.20with.20built-in.20derives.html#210699913">(Sep 21 2020 at 04:06)</a>:</h4>
<p>that would be quite nice</p>



<a name="210700750"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Allow%20skipping%20fields%20with%20built-in%20derives/near/210700750" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Aaron Hill <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Allow.20skipping.20fields.20with.20built-in.20derives.html#210700750">(Sep 21 2020 at 04:31)</a>:</h4>
<p>I'll try to see if those attributes are used within the ecosystem. However,. I don't think we would want to name them anything else, and the compatibility strategy I outlined should allow us to avoid any breakage</p>



<a name="210700890"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Allow%20skipping%20fields%20with%20built-in%20derives/near/210700890" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Aaron Hill <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Allow.20skipping.20fields.20with.20built-in.20derives.html#210700890">(Sep 21 2020 at 04:35)</a>:</h4>
<p>Allowing a fully-qualified path runs into the issues I mentioned - unless we give libstd/libcore the ability to have special helper attrs. However, I'd like to avoid giving bultin derives any abilities that proc-macros don't have (other than the back-compat ignoring, which seems unavoidable)</p>



<a name="210730066"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Allow%20skipping%20fields%20with%20built-in%20derives/near/210730066" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Allow.20skipping.20fields.20with.20built-in.20derives.html#210730066">(Sep 21 2020 at 11:50)</a>:</h4>
<p>Hm, so one note is that serde at least uses serde as the in-struct attribute name for it's two derive macros. I wonder if we should do the same (e.g. std and core). But I think the answer is probably no, because the set of derives in std is pretty orthogonal to each other. Though it might provide another namespace :)</p>



<a name="210768847"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Allow%20skipping%20fields%20with%20built-in%20derives/near/210768847" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> cuviper <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Allow.20skipping.20fields.20with.20built-in.20derives.html#210768847">(Sep 21 2020 at 16:53)</a>:</h4>
<p><a href="https://crates.io/crates/derivative"><code>derivative</code></a> and <a href="https://crates.io/crates/educe"><code>educe</code></a> both use their own name for attributes</p>
<div class="codehilite"><pre><span></span><code><span class="cp">#[derivative(Debug=</span><span class="s">&quot;ignore&quot;</span><span class="cp">)]</span><span class="w"></span>
<span class="cp">#[educe(Debug(ignore))]</span><span class="w"></span>
</code></pre></div>



<a name="210779094"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Allow%20skipping%20fields%20with%20built-in%20derives/near/210779094" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Aaron Hill <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Allow.20skipping.20fields.20with.20built-in.20derives.html#210779094">(Sep 21 2020 at 18:11)</a>:</h4>
<p>It sounds like people are supportive of the general concept (adding builtin derive helper attributes to skip fields). I'm going to start working on a pre-rfc - I don't think the exact naming of the attributes needs to block work on this</p>



<a name="210779314"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Allow%20skipping%20fields%20with%20built-in%20derives/near/210779314" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Aaron Hill <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Allow.20skipping.20fields.20with.20built-in.20derives.html#210779314">(Sep 21 2020 at 18:13)</a>:</h4>
<p>My hope is that we could also use helper attributes to allow relaxing the bounds on parameters (e.g. not requiring <code>T: Debug</code>). However, I'll leave that for a future RFC, as there's significantly more to discuss</p>



<a name="210781328"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Allow%20skipping%20fields%20with%20built-in%20derives/near/210781328" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scottmcm <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Allow.20skipping.20fields.20with.20built-in.20derives.html#210781328">(Sep 21 2020 at 18:29)</a>:</h4>
<p>nit: <span class="user-mention" data-user-id="125294">@Aaron Hill</span> I think this is technically t-libs, not t-lang?  Conceptually the built-in derives are just <a href="https://doc.rust-lang.org/nightly/std/marker/macro.Copy.html">macros provided by the library</a> (though t-libs-impl may choose to build them into the compiler directly if they so wish, of course).  So you might want to raise it over there first.</p>
<p>I guess the lang thing is making them special to avoid impacting existing attributes?  It feels like if there's a conflict-between-proc-macro-attributes problem here we would ideally solve that more generally than "well std has some special ones"...</p>



<a name="210781591"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Allow%20skipping%20fields%20with%20built-in%20derives/near/210781591" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Allow.20skipping.20fields.20with.20built-in.20derives.html#210781591">(Sep 21 2020 at 18:31)</a>:</h4>
<p>Whoa, I just took a look at the source code for that:</p>
<div class="codehilite"><pre><span></span><code><span class="cp">#[rustc_builtin_macro]</span><span class="w"></span>
<span class="cp">#[stable(feature = </span><span class="s">&quot;builtin_macro_prelude&quot;</span><span class="cp">, since = </span><span class="s">&quot;1.38.0&quot;</span><span class="cp">)]</span><span class="w"></span>
<span class="cp">#[allow_internal_unstable(core_intrinsics, derive_clone_copy)]</span><span class="w"></span>
<span class="k">pub</span><span class="w"> </span><span class="kr">macro</span><span class="w"> </span><span class="nb">Copy</span><span class="p">(</span><span class="cp">$item</span>:<span class="nc">item</span><span class="p">)</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="cm">/* compiler built-in */</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>
</code></pre></div>


<p>Since when is <code>macro</code> a keyword? Can that syntax be used for anything except intrinsic macros?</p>



<a name="210781623"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Allow%20skipping%20fields%20with%20built-in%20derives/near/210781623" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jane Lusby <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Allow.20skipping.20fields.20with.20built-in.20derives.html#210781623">(Sep 21 2020 at 18:31)</a>:</h4>
<p>thats from macros 2.0</p>



<a name="210781641"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Allow%20skipping%20fields%20with%20built-in%20derives/near/210781641" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jane Lusby <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Allow.20skipping.20fields.20with.20built-in.20derives.html#210781641">(Sep 21 2020 at 18:32)</a>:</h4>
<p>you can use that on nightly</p>



<a name="210781703"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Allow%20skipping%20fields%20with%20built-in%20derives/near/210781703" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scottmcm <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Allow.20skipping.20fields.20with.20built-in.20derives.html#210781703">(Sep 21 2020 at 18:32)</a>:</h4>
<p><code>macro</code> is reserved for the <del>mythical</del> "Macros 2.0" that will be like macro_rules but better.  (More control over hygiene, for example.)</p>



<a name="210781805"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Allow%20skipping%20fields%20with%20built-in%20derives/near/210781805" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Allow.20skipping.20fields.20with.20built-in.20derives.html#210781805">(Sep 21 2020 at 18:33)</a>:</h4>
<p>i think an attribute per derive is way overkill. can't we have some sort of <code>derive_skip</code> attribute that says "skip this" or optionally <code>derive_skip(eq, hash)</code> or something if you only want it skipped for some things? And then not every single derive, both in and out of the standard library, is making up its own convention about how to mark a field you want ignored.</p>



<a name="210782328"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Allow%20skipping%20fields%20with%20built-in%20derives/near/210782328" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Aaron Hill <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Allow.20skipping.20fields.20with.20built-in.20derives.html#210782328">(Sep 21 2020 at 18:37)</a>:</h4>
<p><span class="user-mention" data-user-id="224471">@Lokathor</span> My intention is for these attributes to be usable for more fine-grained control over the output produced by derive macros. For example, something like <code>#[derive(Debug)] struct Foo&lt;#[Debug(no_bound)] T&gt;  { val: PhantomData&lt;T&gt; }</code> would be made possible by this RFC, without needing to introduce new attributes</p>



<a name="210782449"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Allow%20skipping%20fields%20with%20built-in%20derives/near/210782449" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Allow.20skipping.20fields.20with.20built-in.20derives.html#210782449">(Sep 21 2020 at 18:38)</a>:</h4>
<p>actually that already has a stalled RFC pending</p>



<a name="210782458"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Allow%20skipping%20fields%20with%20built-in%20derives/near/210782458" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Aaron Hill <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Allow.20skipping.20fields.20with.20built-in.20derives.html#210782458">(Sep 21 2020 at 18:38)</a>:</h4>
<p>also, I'm not certain that 'skipping' is broadly applicable enough for an attribute to make sense</p>



<a name="210782484"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Allow%20skipping%20fields%20with%20built-in%20derives/near/210782484" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Aaron Hill <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Allow.20skipping.20fields.20with.20built-in.20derives.html#210782484">(Sep 21 2020 at 18:39)</a>:</h4>
<p>For example, serde allows you to skip fields for serializing, deserializing, or both</p>



<a name="210782510"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Allow%20skipping%20fields%20with%20built-in%20derives/near/210782510" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Aaron Hill <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Allow.20skipping.20fields.20with.20built-in.20derives.html#210782510">(Sep 21 2020 at 18:39)</a>:</h4>
<p>it probably would not want to use <code>derive_skip</code>, because that makes it unclear what exactly is being skipped</p>



<a name="210782619"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Allow%20skipping%20fields%20with%20built-in%20derives/near/210782619" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Aaron Hill <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Allow.20skipping.20fields.20with.20built-in.20derives.html#210782619">(Sep 21 2020 at 18:40)</a>:</h4>
<p>imho, using the macro name (e.g. <code>#[PartialEq(skip)]</code>) makes it clear that what it means to 'skip' a field is specific to the particular derive macro being used</p>



<a name="210782719"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Allow%20skipping%20fields%20with%20built-in%20derives/near/210782719" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Allow.20skipping.20fields.20with.20built-in.20derives.html#210782719">(Sep 21 2020 at 18:41)</a>:</h4>
<p>skip(Serialize) seems identical to serialize(skip), except that one of them puts all the skips under a common prefix</p>



<a name="210782783"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Allow%20skipping%20fields%20with%20built-in%20derives/near/210782783" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Aaron Hill <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Allow.20skipping.20fields.20with.20built-in.20derives.html#210782783">(Sep 21 2020 at 18:41)</a>:</h4>
<p>but <code>serde</code> also has <code>skip_serializing_if</code></p>



<a name="210782799"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Allow%20skipping%20fields%20with%20built-in%20derives/near/210782799" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Aaron Hill <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Allow.20skipping.20fields.20with.20built-in.20derives.html#210782799">(Sep 21 2020 at 18:41)</a>:</h4>
<p>which is probably not something that makes sense for arbitrary <code>derive</code> macros</p>



<a name="210782899"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Allow%20skipping%20fields%20with%20built-in%20derives/near/210782899" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Allow.20skipping.20fields.20with.20built-in.20derives.html#210782899">(Sep 21 2020 at 18:42)</a>:</h4>
<p>within skip nothing is stopping serialize from accepting more args</p>



<a name="210782923"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Allow%20skipping%20fields%20with%20built-in%20derives/near/210782923" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Allow.20skipping.20fields.20with.20built-in.20derives.html#210782923">(Sep 21 2020 at 18:42)</a>:</h4>
<p>ah, here's that RFC i mentioned, <a href="https://github.com/rust-lang/rfcs/pull/2353">https://github.com/rust-lang/rfcs/pull/2353</a></p>



<a name="210782928"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Allow%20skipping%20fields%20with%20built-in%20derives/near/210782928" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Aaron Hill <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Allow.20skipping.20fields.20with.20built-in.20derives.html#210782928">(Sep 21 2020 at 18:42)</a>:</h4>
<p>hmm</p>



<a name="210783098"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Allow%20skipping%20fields%20with%20built-in%20derives/near/210783098" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Allow.20skipping.20fields.20with.20built-in.20derives.html#210783098">(Sep 21 2020 at 18:44)</a>:</h4>
<p>my concern is a namespace clogging one. with one attribute for derive skips, it's clear that's what's going on, minimal top level conflicts. <em>within</em> that attribute usage you can go back to being arbitratily complicated and no one cares because it doens't name clash with what they're doing.</p>



<a name="210783168"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Allow%20skipping%20fields%20with%20built-in%20derives/near/210783168" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Aaron Hill <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Allow.20skipping.20fields.20with.20built-in.20derives.html#210783168">(Sep 21 2020 at 18:45)</a>:</h4>
<p>My concern is that we'll run into the namespace issue again if we ever want to allow more customization of builtin derives</p>



<a name="210783178"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Allow%20skipping%20fields%20with%20built-in%20derives/near/210783178" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Aaron Hill <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Allow.20skipping.20fields.20with.20built-in.20derives.html#210783178">(Sep 21 2020 at 18:45)</a>:</h4>
<p>e.g. the RFC you linked</p>



<a name="210783204"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Allow%20skipping%20fields%20with%20built-in%20derives/near/210783204" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Aaron Hill <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Allow.20skipping.20fields.20with.20built-in.20derives.html#210783204">(Sep 21 2020 at 18:45)</a>:</h4>
<p>but perhaps that just points the need to some form of namespacing (as <span class="user-mention" data-user-id="125270">@scottmcm</span> mentioned)</p>



<a name="210783219"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Allow%20skipping%20fields%20with%20built-in%20derives/near/210783219" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Allow.20skipping.20fields.20with.20built-in.20derives.html#210783219">(Sep 21 2020 at 18:45)</a>:</h4>
<p>there's only two hard things in programming, and naming is one of them.</p>



<a name="210783563"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Allow%20skipping%20fields%20with%20built-in%20derives/near/210783563" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scottmcm <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Allow.20skipping.20fields.20with.20built-in.20derives.html#210783563">(Sep 21 2020 at 18:48)</a>:</h4>
<p>(The other is cache invalidation and off-by-one errors.)</p>



<a name="210783616"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Allow%20skipping%20fields%20with%20built-in%20derives/near/210783616" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Aaron Hill <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Allow.20skipping.20fields.20with.20built-in.20derives.html#210783616">(Sep 21 2020 at 18:48)</a>:</h4>
<p>I strongly believe that we shouldn't make helper attributes importable items (like attribute macros). The only way for proc-macros to reliably handle such attributes would be for rustc to 'normalize' the attribute before invoking the proc-macro, which seems to violate the whole spirit of proc macros (you get the exact tokens written by the user,  to the greatest extent possible).</p>
<p>Unfortuntely, that doesn't leave us with many options</p>



<a name="210930911"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Allow%20skipping%20fields%20with%20built-in%20derives/near/210930911" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Aaron Hill <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Allow.20skipping.20fields.20with.20built-in.20derives.html#210930911">(Sep 22 2020 at 21:03)</a>:</h4>
<p>Here's an idea for namespacing helper attributes - we allow prefixing them with a path to the derive macro.<br>
E.g. <code>#[derive(Debug)] struct Foo { #[Debug::debug(skip)] field: u8 }</code></p>
<p>When invoking the derive macro, we strip off the prefix if it matches the macro being invoked.</p>
<p>So, in <code>#[derive(Debug, CustomDerive)] struct Foo { #[Debug::debug(skip)] val: u8 }</code>, the <code>Debug</code> macro would see <code>struct Foo { #[debug(skip)] field: u8 }</code>, while the <code>CustomDerive</code> macro would see <code>struct Foo { #[Debug::debug(skip)] field: u8 }</code></p>
<p>We would still be modifying the tokens passed to the macro, but we are only <em>removing</em> tokens, so there are no issues with spans. We need to do this for <code>#[cfg]</code> attributes anyway, so it's not as if derive macros previous received the exact input in all cases.</p>
<p>This has the downside of making derive macros see different versions of the same code. However, derive macros can only emit new tokens, so this os only observable of a derive macro decides to re-emit a helper attribute. Also, attribute macros currently see different 'views' of a target (it depends on the order they occur in), so there's precedent for this.</p>



<a name="210931104"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Allow%20skipping%20fields%20with%20built-in%20derives/near/210931104" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Aaron Hill <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Allow.20skipping.20fields.20with.20built-in.20derives.html#210931104">(Sep 22 2020 at 21:05)</a>:</h4>
<p>If the path isn't fully qualified, there could be an ambiguity (e.g you have <code>use some_crate::Debug</code> in scope, where <code>Debug</code> is a module), but that can just be a hard error. Specifiyng a fully-qualified path should always resolve the ambiguity.</p>



<a name="210931604"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Allow%20skipping%20fields%20with%20built-in%20derives/near/210931604" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Aaron Hill <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Allow.20skipping.20fields.20with.20built-in.20derives.html#210931604">(Sep 22 2020 at 21:10)</a>:</h4>
<p>This would allow us to introduce builtin derive helpers without needing a permanent special case for the standard library. We would still want to ignore them for builtin derives in cases of overlap (to avoid affecting existing code), but this could be changed in a future edition.</p>



<a name="210931691"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Allow%20skipping%20fields%20with%20built-in%20derives/near/210931691" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Aaron Hill <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Allow.20skipping.20fields.20with.20built-in.20derives.html#210931691">(Sep 22 2020 at 21:11)</a>:</h4>
<p><span class="user-mention" data-user-id="123856">@Vadim Petrochenkov</span> any objections to the above strategy for disambiguating derive helper attributes? If not, I'll work on a pre-RFC</p>



<a name="210945087"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Allow%20skipping%20fields%20with%20built-in%20derives/near/210945087" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> tmandry <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Allow.20skipping.20fields.20with.20built-in.20derives.html#210945087">(Sep 22 2020 at 23:51)</a>:</h4>
<p>If we do that, is there any reason it couldn't be <code>#[Debug::skip]</code>?</p>



<a name="210946464"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Allow%20skipping%20fields%20with%20built-in%20derives/near/210946464" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Allow.20skipping.20fields.20with.20built-in.20derives.html#210946464">(Sep 23 2020 at 00:13)</a>:</h4>
<p>Either <code>Debug(skip)</code> or <code>Debug::skip</code> seems reasonable.</p>



<a name="210946578"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Allow%20skipping%20fields%20with%20built-in%20derives/near/210946578" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Aaron Hill <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Allow.20skipping.20fields.20with.20built-in.20derives.html#210946578">(Sep 23 2020 at 00:15)</a>:</h4>
<p>The idea is for this to be an alternate way of specifying the normal helper name. So, the normal form would be <code>#[debug(skip)]</code>, disambiguated as <code>#[Debug::debug(skip)]</code></p>



<a name="210946589"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Allow%20skipping%20fields%20with%20built-in%20derives/near/210946589" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Aaron Hill <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Allow.20skipping.20fields.20with.20built-in.20derives.html#210946589">(Sep 23 2020 at 00:16)</a>:</h4>
<p><code>#[Debug::skip]</code> would mean that <code>Debug</code> defined a helper attr named <code>skip</code></p>



<a name="210946644"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Allow%20skipping%20fields%20with%20built-in%20derives/near/210946644" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Aaron Hill <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Allow.20skipping.20fields.20with.20built-in.20derives.html#210946644">(Sep 23 2020 at 00:16)</a>:</h4>
<p>I think <code>Debug(skip)</code> looks too much like another invocation of <code>Debug</code></p>



<a name="210946882"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Allow%20skipping%20fields%20with%20built-in%20derives/near/210946882" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Aaron Hill <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Allow.20skipping.20fields.20with.20built-in.20derives.html#210946882">(Sep 23 2020 at 00:21)</a>:</h4>
<p>the disambiguated syntax does look weird, but the idea is that it would almost never need to be used</p>



<a name="210946899"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Allow%20skipping%20fields%20with%20built-in%20derives/near/210946899" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Aaron Hill <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Allow.20skipping.20fields.20with.20built-in.20derives.html#210946899">(Sep 23 2020 at 00:21)</a>:</h4>
<p>it's just to prevent a situtation where combining two derives macros becomes impossible</p>



<a name="210955036"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Allow%20skipping%20fields%20with%20built-in%20derives/near/210955036" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Allow.20skipping.20fields.20with.20built-in.20derives.html#210955036">(Sep 23 2020 at 03:01)</a>:</h4>
<p>Ah, I see.</p>



<a name="210958446"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Allow%20skipping%20fields%20with%20built-in%20derives/near/210958446" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Vadim Petrochenkov <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Allow.20skipping.20fields.20with.20built-in.20derives.html#210958446">(Sep 23 2020 at 04:28)</a>:</h4>
<p><span class="user-mention" data-user-id="125294">@Aaron Hill</span> I'll try to read this thread this evening.</p>



<a name="211060017"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Allow%20skipping%20fields%20with%20built-in%20derives/near/211060017" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Vadim Petrochenkov <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Allow.20skipping.20fields.20with.20built-in.20derives.html#211060017">(Sep 23 2020 at 20:45)</a>:</h4>
<p>I really dislike the idea of introducing new language features for this, and suggest to use the existing mechanism of helper attributes as if <code>Debug</code> were a regular third-party proc macro (which it could totally be, proc macros being implemented in a compiler crate rather than in a regular proc macro crate is more like an implementation detail).</p>



<a name="211060196"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Allow%20skipping%20fields%20with%20built-in%20derives/near/211060196" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Vadim Petrochenkov <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Allow.20skipping.20fields.20with.20built-in.20derives.html#211060196">(Sep 23 2020 at 20:46)</a>:</h4>
<p>Since helper attributes are pretty fundamentally global due to proc macros having to do simple textual match instead of name resolution, I suggest to deal with possible ambiguities by using an unique enough name.</p>



<a name="211060366"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Allow%20skipping%20fields%20with%20built-in%20derives/near/211060366" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Aaron Hill <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Allow.20skipping.20fields.20with.20built-in.20derives.html#211060366">(Sep 23 2020 at 20:48)</a>:</h4>
<p>My concern is about what will happen if there is a collision</p>



<a name="211060504"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Allow%20skipping%20fields%20with%20built-in%20derives/near/211060504" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Aaron Hill <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Allow.20skipping.20fields.20with.20built-in.20derives.html#211060504">(Sep 23 2020 at 20:49)</a>:</h4>
<p>if the collision was with a normal importable name, the user would get an error</p>



<a name="211060588"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Allow%20skipping%20fields%20with%20built-in%20derives/near/211060588" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Aaron Hill <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Allow.20skipping.20fields.20with.20built-in.20derives.html#211060588">(Sep 23 2020 at 20:50)</a>:</h4>
<p>However, an overlap with derive helper attributes could cause the behavior to silently change when the compiler is updated</p>



<a name="211060604"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Allow%20skipping%20fields%20with%20built-in%20derives/near/211060604" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Vadim Petrochenkov <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Allow.20skipping.20fields.20with.20built-in.20derives.html#211060604">(Sep 23 2020 at 20:50)</a>:</h4>
<p>(Also, helper attributes are actually importable due to 2018 edition uniform imports, see <a href="https://github.com/rust-lang/rust/pull/64694">https://github.com/rust-lang/rust/pull/64694</a>, but there's a rule preventing their use in imported form, so proc macros still can do textual matching. This is very similar to <a href="#narrow/stream/122651-general/topic/What's.20the.20deal.20with.20importing.20builtin.20attributes.3F">https://rust-lang.zulipchat.com/#narrow/stream/122651-general/topic/What's.20the.20deal.20with.20importing.20builtin.20attributes.3F</a>)</p>



<a name="211060700"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Allow%20skipping%20fields%20with%20built-in%20derives/near/211060700" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Aaron Hill <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Allow.20skipping.20fields.20with.20built-in.20derives.html#211060700">(Sep 23 2020 at 20:51)</a>:</h4>
<p>my initial idea was ignore them in builtin derives if there was an overlap, but I think <span class="user-mention" data-user-id="125270">@scottmcm</span> was worried about making the special library extra special with regard to macros</p>



<a name="211060707"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Allow%20skipping%20fields%20with%20built-in%20derives/near/211060707" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Vadim Petrochenkov <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Allow.20skipping.20fields.20with.20built-in.20derives.html#211060707">(Sep 23 2020 at 20:51)</a>:</h4>
<p><span class="user-mention silent" data-user-id="125294">Aaron Hill</span> <a href="#narrow/stream/213817-t-lang/topic/Allow.20skipping.20fields.20with.20built-in.20derives/near/211060366">said</a>:</p>
<blockquote>
<p>My concern is about what will happen if there is a collision</p>
</blockquote>
<p>What third-party proc macros do if there's a collision? We should do the same thing.<br>
(That probably again means unique enough names.)</p>



<a name="211060739"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Allow%20skipping%20fields%20with%20built-in%20derives/near/211060739" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Aaron Hill <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Allow.20skipping.20fields.20with.20built-in.20derives.html#211060739">(Sep 23 2020 at 20:51)</a>:</h4>
<p>With third party macros, the crate using them can control the dependency versions</p>



<a name="211060805"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Allow%20skipping%20fields%20with%20built-in%20derives/near/211060805" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Aaron Hill <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Allow.20skipping.20fields.20with.20built-in.20derives.html#211060805">(Sep 23 2020 at 20:52)</a>:</h4>
<p>so they at least have a chance of defending against overlap by checking release notes before upgrading</p>



<a name="211060854"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Allow%20skipping%20fields%20with%20built-in%20derives/near/211060854" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Aaron Hill <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Allow.20skipping.20fields.20with.20built-in.20derives.html#211060854">(Sep 23 2020 at 20:52)</a>:</h4>
<p>when it's the standard library introducing helper attributes, they may not realize there's a conflict if they test on older versions of Rust</p>



<a name="211060867"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Allow%20skipping%20fields%20with%20built-in%20derives/near/211060867" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Aaron Hill <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Allow.20skipping.20fields.20with.20built-in.20derives.html#211060867">(Sep 23 2020 at 20:52)</a>:</h4>
<p>but their downstream users will get silent behavior changes</p>



<a name="211061030"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Allow%20skipping%20fields%20with%20built-in%20derives/near/211061030" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Aaron Hill <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Allow.20skipping.20fields.20with.20built-in.20derives.html#211061030">(Sep 23 2020 at 20:54)</a>:</h4>
<p>My hope is that this almost never comes up in practice, but I'm uncomfortable with users having no way of defending against this (other than reading the release notes for every single rust update, and auditing every single derive invocation in their crate)</p>



<a name="211061046"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Allow%20skipping%20fields%20with%20built-in%20derives/near/211061046" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Vadim Petrochenkov <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Allow.20skipping.20fields.20with.20built-in.20derives.html#211061046">(Sep 23 2020 at 20:54)</a>:</h4>
<p>These compatibility issues are theoretical so far. I suggest to use names that are unlikely to cause conflicts and check it with crater.</p>



<a name="211061154"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Allow%20skipping%20fields%20with%20built-in%20derives/near/211061154" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Vadim Petrochenkov <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Allow.20skipping.20fields.20with.20built-in.20derives.html#211061154">(Sep 23 2020 at 20:55)</a>:</h4>
<p>Alternatively, we can <em>encourage</em> this "overlap" and reuse the single built-in attribute <code>#[ignore]</code> to tell <em>all</em> derives to ignore the field on which it is placed.</p>



<a name="211061228"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Allow%20skipping%20fields%20with%20built-in%20derives/near/211061228" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Aaron Hill <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Allow.20skipping.20fields.20with.20built-in.20derives.html#211061228">(Sep 23 2020 at 20:56)</a>:</h4>
<p>I don't think we should have a single attribute - there are legitimate usecases for only ignoring certain derives</p>



<a name="211061248"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Allow%20skipping%20fields%20with%20built-in%20derives/near/211061248" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Aaron Hill <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Allow.20skipping.20fields.20with.20built-in.20derives.html#211061248">(Sep 23 2020 at 20:56)</a>:</h4>
<p>E.g. a <code>#[derive(PartialEq, Debug)]</code> struct with a non-debuggable type</p>



<a name="211061293"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Allow%20skipping%20fields%20with%20built-in%20derives/near/211061293" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Vadim Petrochenkov <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Allow.20skipping.20fields.20with.20built-in.20derives.html#211061293">(Sep 23 2020 at 20:57)</a>:</h4>
<p>They will still need to be written manually then.<br>
(Derive is still a sugar for common cases after all.)</p>



<a name="211061329"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Allow%20skipping%20fields%20with%20built-in%20derives/near/211061329" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Vadim Petrochenkov <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Allow.20skipping.20fields.20with.20built-in.20derives.html#211061329">(Sep 23 2020 at 20:57)</a>:</h4>
<p>Or we can use <code>#[ignore(Debug)]</code>.</p>



<a name="211061876"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Allow%20skipping%20fields%20with%20built-in%20derives/near/211061876" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Aaron Hill <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Allow.20skipping.20fields.20with.20built-in.20derives.html#211061876">(Sep 23 2020 at 21:02)</a>:</h4>
<p>My worry about encouraging overlap is that it gives us no way to distinguish between intentional and unintentional overlap (e.g. a custom derive that already interprets <code>#[ignore(Debug)]</code> for some reason.</p>



<a name="211061913"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Allow%20skipping%20fields%20with%20built-in%20derives/near/211061913" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Aaron Hill <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Allow.20skipping.20fields.20with.20built-in.20derives.html#211061913">(Sep 23 2020 at 21:02)</a>:</h4>
<p>I really hope no one is currently doing that, but I really dislike the idea of silent behavior change</p>



<a name="211062889"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Allow%20skipping%20fields%20with%20built-in%20derives/near/211062889" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Vadim Petrochenkov <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Allow.20skipping.20fields.20with.20built-in.20derives.html#211062889">(Sep 23 2020 at 21:11)</a>:</h4>
<p><a href="https://github.com/rust-lang/rfcs/pull/2353">https://github.com/rust-lang/rfcs/pull/2353</a> appears to encourage overlap as well (single attribute for all macros, built-in and third-party).<br>
It and also doesn't consider potential breakage from macros already using <code>#[derive_no_bound]</code> and <code>#[derive_field_bound]</code> as helpers.</p>



<a name="211063255"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Allow%20skipping%20fields%20with%20built-in%20derives/near/211063255" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Vadim Petrochenkov <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Allow.20skipping.20fields.20with.20built-in.20derives.html#211063255">(Sep 23 2020 at 21:14)</a>:</h4>
<p>Ok, I still think we should try the simplest thing first  - just add a regular helper (or reuse a built-in), and start thinking about problems only if they actually appear.</p>



<a name="211063436"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Allow%20skipping%20fields%20with%20built-in%20derives/near/211063436" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Aaron Hill <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Allow.20skipping.20fields.20with.20built-in.20derives.html#211063436">(Sep 23 2020 at 21:16)</a>:</h4>
<p>I'll do a crater run so we can get a lower bound on the amount of breakage</p>



<a name="211063460"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Allow%20skipping%20fields%20with%20built-in%20derives/near/211063460" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Aaron Hill <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Allow.20skipping.20fields.20with.20built-in.20derives.html#211063460">(Sep 23 2020 at 21:16)</a>:</h4>
<p>there's only one item in the queue atm</p>



<a name="211330057"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Allow%20skipping%20fields%20with%20built-in%20derives/near/211330057" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Aaron Hill <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Allow.20skipping.20fields.20with.20built-in.20derives.html#211330057">(Sep 25 2020 at 23:48)</a>:</h4>
<p>The crater run didn't even start - bootstrapping failed, since chalk deliberately overlaps helper attributes</p>



<a name="211330095"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Allow%20skipping%20fields%20with%20built-in%20derives/near/211330095" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Aaron Hill <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Allow.20skipping.20fields.20with.20built-in.20derives.html#211330095">(Sep 25 2020 at 23:49)</a>:</h4>
<p>which would seem to suggest that overlapping helper attributes might be somewhat common in practice</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>